﻿using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Text;
using ZYHand.DTO;
using ZYHand.Entity;
using ZYHand.IRepository;
using ZYHand.IService;
using ZYHand.Repository;

namespace ZYHand.Service
{
    public class ElasticSearchService: IElasticSearchService
    {
        public bool Post<T>(string index, T data) where T : class, new()
        {
            IElasticSearchRepository elasticSearchRepository = new ElasticSearchRepository();
            var isPost = elasticSearchRepository.Post<T>(index, data);
            return isPost;
        }


        public bool PostByString(string index, ExpandoObject data) 
        {
            IElasticSearchRepository elasticSearchRepository = new ElasticSearchRepository();
            var isPost = elasticSearchRepository.PostByString(index, data);
            return isPost;
        }

        public SearchData<T> Match<T>(string keywords, string index, int from, int size)
        {
            IElasticSearchRepository elasticSearchRepository = new ElasticSearchRepository();
            return elasticSearchRepository.Match<T>(keywords, index, from,size);
        }

    }
}
